package com.packer.ipc;

import java.net.InetSocketAddress;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.ipc.RPC;
/**
 * Created by qiaqia on 2016/11/16.
 */
public class RPCClient {
    private MyRpcProtocal protocal;

    public RPCClient() throws Exception{
        InetSocketAddress address = new InetSocketAddress("localhost",9999);

        protocal = (MyRpcProtocal)RPC.waitForProxy
                (MyRpcProtocal.class,MyRpcProtocal.versionID, address, new Configuration());
        //RPC.setProtocolEngine(new Configuration(), MyRPCProtocal.class, RpcEngine.class);
    }

    public void call(String s){
        final Text string = protocal.test(new Text(s));
        System.out.println(string.toString());
    }

    public static void main(String[] args) throws Exception {
        RPCClient client = new RPCClient();
        client.call("RPC");
    }
}
